package org.example;

import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.UUID;

@RestController
@RequestMapping("code")
public class KDemo {

    @Resource
    KafkaTemplate<String, Object> kTemplate;

    @GetMapping("ktest")
    public void ktest(String topic, String message) throws IOException {
        kTemplate.send(topic,"aa", UUID.randomUUID().toString());
    }

    @KafkaListener(groupId = "aa", topics = "kk")
    public void listen(String input) {
        System.out.println("->" + input);
    }
}

